<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<h1>
	<fmt:message key="shop.list.title" />
</h1>
<table class="search">
	<tr>
		<th><fmt:message key="shop.form.login" /></th>
	</tr>
	<c:forEach var="shop" items="${list}" varStatus="status">
		<tr>
			<c:set var="shopFormId" value="shop${status.index}" />

			<c:url var="editUrl" value="/shop/form.html">
				<c:param name="id" value="${shop.id}" />
			</c:url>

			<sec:authorize ifAllGranted="ROLE_ADMIN">
				<c:url var="deleteUrl" value="/shop/delete.html" />
				<form id="${shopFormId}" action="${deleteUrl}" method="POST">
					<input id="id" name="id" type="hidden" value="${shop.id}" />
				</form>
			</sec:authorize>

			<td>${shop.nameShop}</td>
			
			<td>
				<a href='<c:out value="${editUrl}"/>'><fmt:message key="button.edit" /></a> 
				<sec:authorize ifAllGranted="ROLE_ADMIN">
					<a href="javascript:document.forms['${shopFormId}'].submit();"><fmt:message key="button.delete" /></a>
				</sec:authorize>
			</td>
		</tr>
	</c:forEach>
</table>